<?php

class html2text extends tecler {
	
	var $mode;
	
	function _cdata( $code ){
		switch( $this->mode ){
			case 'emphasis': 
				return strtoupper( $code );
			case 'silent': 
				return '';
			case 'strong': 
				return preg_replace( '/(.)/', '$1 ',  strtoupper( $code ) );
			default:
				return $code;
		}
	}
	
	function _default(){
		return '';
	}
	
	function _getname( $string ){
		if( substr( $string, 0, 1 ) == '/' ){
			return substr( $string, 1 ) . '_end';
		} else {
			return $string;
		}
	}
	
	function b(){
		$this->mode = 'strong';
	}

	function b_end(){
		$this->mode = '';
	}

	function br(){
		return "\n";
	}

	function em(){
		if( $this->mode != 'strong' ){
			$this->mode = 'emphasis';
		}
	}

	function em_end(){
		$this->mode = '';
	}

	function head(){
		$this->mode = 'silent';
	}

	function head_end(){
		$this->mode = '';
	}

	function i(){
		if( $this->mode != 'strong' ){
			$this->mode = 'emphasis';
		}
	}

	function i_end(){
		$this->mode = '';
	}

	function p(){
		return "\n\n";
	}

	function strong(){
		$this->mode = 'strong';
	}

	function strong_end(){
		$this->mode = '';
	}

}

?>